package com.atguigu.stgy.admin.converter;

import com.atguigu.stgy.model.enums.LabelTypeEnum;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;


@Component
public class LabelTyepEnumConverter implements Converter<String, LabelTypeEnum> {


    @Override
    public LabelTypeEnum convert(String source) {
        for(LabelTypeEnum typeEnum:LabelTypeEnum.values()){
            if (typeEnum.getType().toString().equals(source)){
                return typeEnum;
            }
        }

        throw new IllegalArgumentException("标签类型不存在");
    }
}